package com.heima.user.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.common.dto.User;
import com.heima.user.dto.UserRelationDto;
import com.heima.user.entity.ApUser;
import com.heima.user.service.IApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/user")
@CrossOrigin
public class ApUserController {
    @Autowired
    private IApUserService apUserService;


    @GetMapping("/{id}")
    public ResponseResult<ApUser> getById(@PathVariable("id") Integer id){
        ApUser apUser = apUserService.getById(id);
        return ResponseResult.okResult(apUser);
    }

    /**
     * 关注和取消关注
     * @param dto
     * @return
     */
    @PostMapping("/user_follow")
    public ResponseResult follow(@RequestBody UserRelationDto dto){
        return apUserService.follow(dto);
    }


}
